package com.stm.bi.model;

import com.alibaba.fastjson.JSONObject;
import com.stm.framework.annotation.Param;

import java.math.BigDecimal;

/**
 * 简介
 *
 * @author zhouyuanpeng
 * @date 2024-05-23 11:58
 */
public class BaseOriginData {
    @Param(label = "核心值1")
    protected BigDecimal fieldValue1;

    @Param(label = "核心值2")
    protected BigDecimal fieldValue2;

    @Param(label = "累计核心值1")
    protected BigDecimal cumulativeFieldValue1;

    @Param(label = "累计核心值2")
    protected BigDecimal cumulativeFieldValue2;

    @Param(label = "排序")
    protected BigDecimal sortNum = BigDecimal.ZERO;

    public void initData() {
        if (this.fieldValue1 != null) {
            this.sortNum = this.fieldValue1;
        }
    }

    public void cumulativeData(JSONObject json, String totalType) {
        if (json != null) {
            BaseOriginData obj = JSONObject.toJavaObject(json, BaseOriginData.class);
            if (obj.getFieldValue1() != null) {
                this.cumulativeFieldValue1 = obj.getFieldValue1();
            }
            if (obj.getFieldValue2() != null) {
                this.cumulativeFieldValue2 = obj.getFieldValue2();
            }
        }
    }

    public void totalQty(JSONObject json, String totalType) {
        BaseOriginData obj = JSONObject.toJavaObject(json, BaseOriginData.class);
        if (obj.getFieldValue1() != null) {
            this.fieldValue1 = this.fieldValue1 == null ? obj.getFieldValue1() : this.fieldValue1.add(obj.getFieldValue1());
        }
        if (obj.getFieldValue2() != null) {
            this.fieldValue2 = this.fieldValue2 == null ? obj.getFieldValue2() : this.fieldValue2.add(obj.getFieldValue2());
        }

        if (this.fieldValue1 != null) {
            this.sortNum = this.fieldValue1;
        }
    }

    public BigDecimal getFieldValue1() {
        return fieldValue1;
    }

    public BaseOriginData setFieldValue1(BigDecimal fieldValue1) {
        this.fieldValue1 = fieldValue1;
        return this;
    }

    public BigDecimal getFieldValue2() {
        return fieldValue2;
    }

    public BaseOriginData setFieldValue2(BigDecimal fieldValue2) {
        this.fieldValue2 = fieldValue2;
        return this;
    }

    public BigDecimal getCumulativeFieldValue1() {
        return cumulativeFieldValue1;
    }

    public BaseOriginData setCumulativeFieldValue1(BigDecimal cumulativeFieldValue1) {
        this.cumulativeFieldValue1 = cumulativeFieldValue1;
        return this;
    }

    public BigDecimal getCumulativeFieldValue2() {
        return cumulativeFieldValue2;
    }

    public BaseOriginData setCumulativeFieldValue2(BigDecimal cumulativeFieldValue2) {
        this.cumulativeFieldValue2 = cumulativeFieldValue2;
        return this;
    }

    public BigDecimal getSortNum() {
        return sortNum;
    }

    public BaseOriginData setSortNum(BigDecimal sortNum) {
        this.sortNum = sortNum;
        return this;
    }
}
